package com.plentitude.easytrader.util;

import com.plentitude.easytrader.R;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;


/**
 * We need this layout to hide buttons on Settings page when softkeyboard appears.
 * 
 * @author team@getstarted.com.ua
 */
public class CustomLinearLayout extends LinearLayout {

	public CustomLinearLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public CustomLinearLayout(Context context) {
		super(context);
	}
	
    
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        final int proposedheight = MeasureSpec.getSize(heightMeasureSpec);
        final int actualHeight = getHeight();
        LinearLayout buttons = (LinearLayout) findViewById(R.id.buttons);
        if (actualHeight > proposedheight){
            buttons.setVisibility(View.GONE);
        } else {
        	buttons.setVisibility(View.VISIBLE);
        }

        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
    

}
